package com.bigger.controller;

import com.bigger.clients.AdminClient;
import com.bigger.dto.LoginDTO;
import com.bigger.dto.UpdatePasswordDTO;
import com.bigger.entity.Employee;
import com.bigger.result.Result;
import com.bigger.service.RunnerService;
import com.bigger.vo.LoginVO;
import com.bigger.vo.WagesVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/runner/runner")
public class RunnerController {
    @Autowired
    private AdminClient adminClient;
    @Autowired
    private RunnerService runnerService;

    @PostMapping("/login")
    public Result<LoginVO> login(@RequestBody LoginDTO loginDTO){
        Result<LoginVO> login = adminClient.login(loginDTO);
        return login;
    }
    @PutMapping("/update")
    public Result<String> updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO){
        runnerService.updatePassword(updatePasswordDTO);
        return Result.success("修改成功");
    }
    @GetMapping("/wage")
    public Result<WagesVO> getWage(){
        WagesVO wagesVO=runnerService.getWage();
        return Result.success(wagesVO);
    }
    @GetMapping("/get")
    public Result<Employee> getById(){
        Employee employee=runnerService.getById();
        return Result.success(employee);
    }
}
